package com.service.impl;

import com.dao.ManagerDao1;
import com.service.RbacManagerService;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class RbacManagerServiceImpl implements RbacManagerService {
    ManagerDao1 managerDao;

    public ManagerDao1 getManagerDao() {
        return managerDao;
    }

    public void setManagerDao(ManagerDao1 managerDao) {
        this.managerDao = managerDao;
    }

    @Override
    @Transactional
    public void addOne() {
        Map<String, String> map = new HashMap<>();
        map.put("account","xiaoming");
        map.put("password","123456");
        map.put("status","y");
        int i = managerDao.addOne(map);

        //这句话之前是成功的
//        Map<String, String> one = managerDao.getOne(1255);
        map.put("status","klasjdflkajskldfjaklsdjflasjdlfjlasdf");
        //下面的add方法就要报错
        int j = managerDao.addOne(map);
        //如果没有事务，这个插入是成功的不会回滚。
        if (i>0){
            System.out.println("新增成功");
        }else{
            System.out.println("RbacManagerServiceImpl.addOne执行失败");
        }
    }

    @Override
    public Map findOne() {
        System.out.println("RbacManagerServiceImpl.findOne");
        return null;
    }

    @Override
    public List<Map<String, String>> findAllOne() {
        System.out.println("RbacManagerServiceImpl.findAllOne");
        return null;
    }

    @Override
    public int deleteOne(int id) {
        System.out.println("RbacManagerServiceImpl.deleteOne,现在获取到的id是多少："+id);
        return 0;
    }
}
